package com.zq.controller;

import com.zq.entity.Type;
import com.zq.entity.User;
import com.zq.repository.TypeRepository;
import com.zq.service.TypeService;
import com.zq.utils.FenyeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author:任人渐疏
 * @Date:Created in 11:44 上午 2020/6/27
 * Update:true
 */
@RequestMapping("type")
@RestController
public class TypeController {
    @Autowired
    private TypeRepository typeRepository;
    @Autowired
    private TypeService typeService;

    @GetMapping
    public  Object getAllList(Type type,Integer page){
        return typeService.findAllList(type,page);
    }
    @PostMapping
    public  Object tianjiaType(Type type){
        return  typeService.addType(type);
    }
    @PutMapping
    public  Object xiugaiType(Type type){
        return  typeService.updateType(type);
    }
    @DeleteMapping
    public  Object deleteUser(String tid){
        return typeService.deleteType(tid);
    }
    @GetMapping("jianchaType")
    public  Object jianchaType(String tname){
        return typeRepository.findByTagName(tname);
    }
    @GetMapping("getAllType")
    public  Object getAllType(){
        return  typeRepository.getAllType();
    }
}
